package com.newgrand.annexserver.config;

import com.newgrand.annexserver.filter.DataSourceFilter;
import com.newgrand.annexserver.service.DbconfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Arrays;

/**
 * @author ：minyang
 * @date ：Created in 2019/9/8 16:09
 */
@Configuration
public class WebConfig {

    @Autowired
    DbconfigService dbconfigService;


    @Bean
    public FilterRegistrationBean dataSourceFilter() {
        FilterRegistrationBean registrationBean = new FilterRegistrationBean();
        registrationBean.setFilter(new DataSourceFilter(dbconfigService));
        registrationBean.setUrlPatterns(Arrays.asList("/file/*"));
        return registrationBean;
    }
}
